﻿Namespace ViewModel
    Public Class MainWindow
        Implements IDisposable

#Region " Public Properties "

        Public ReadOnly Property SolutionOptions As DataModel.SolutionOptions
            Get
                If m_SolutionOptions Is Nothing Then
                    m_SolutionOptions = DeserializeFromXMLFile(Of DataModel.SolutionOptions)(My.Computer.FileSystem.CombinePath(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData, "SolutionOptions.xml"))
                    Dim root As DataModel.SolutionOptions
                    If m_SolutionOptions.ChildOptions.Count = 0 Then
                        root = New DataModel.SolutionOptions With {.SolutionName = "Root"}
                        m_SolutionOptions.ChildOptions.Add(root)
                    Else
                        root = m_SolutionOptions.ChildOptions(0)
                    End If

                    root.IsSelected = True
                End If
                Return m_SolutionOptions
            End Get
        End Property
        Private m_SolutionOptions As DataModel.SolutionOptions

#End Region

#Region " Dispose "

        Public Sub Dispose() Implements IDisposable.Dispose
            Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub
        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If m_SolutionOptions IsNot Nothing Then
                    m_SolutionOptions.Dispose()
                    m_SolutionOptions = Nothing
                End If
            End If
        End Sub
        Protected Overrides Sub Finalize()
            Dispose(False)
        End Sub
#End Region

    End Class

End Namespace

